package hsl.study.utils;


import org.springframework.ai.tool.annotation.Tool;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description:
 * @Author: hsl
 * @CreateDate: 2025/8/4 12:26
 * @Version: 1.0
 */


public class ExpressTools {
    @Tool(description = "查询快递信息")
    public List<Express> getExpress(String state) {
        // 快递数据
        List<Express> expressList = this.getData();
        return expressList.stream()
                .filter(express -> express.state.equalsIgnoreCase(state)).collect(Collectors.toList());
    }

    private List<Express> getData() {

        List<Express> expressList = new ArrayList<>();

        LocalDateTime now = LocalDateTime.now();

        expressList.add(new Express(1001L, "上海", "北京", now, "未发货"));
        expressList.add(new Express(1002L, "北京", "南京", now, "在途中"));
        expressList.add(new Express(1003L, "南京", "广州", now, "已签收"));
        expressList.add(new Express(1004L, "广州", "邯郸", now, "已退款"));
        expressList.add(new Express(1005L, "邯郸", "上海", now, "运送中"));

        return expressList;
    }

    record Express(Long id, String from, String to, LocalDateTime createTime, String state) {
    }
}
